package com.koron.system.role.mapper;

import com.koron.bean.app.AppSimpleBean;
import com.koron.bean.base.BaseQueryBean;
import com.koron.bean.system.menu.MenuFuncBean;
import com.koron.bean.system.role.*;
import com.koron.system.common.util.MenuTreeVo;
import com.koron.system.role.bean.OrgTypeTreeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName RoleMapper
 * @description
 * @Author zhouj
 * @Date 2021/7/22 14:26
 */
@Component
@Mapper
public interface RoleMapper {

    int insertRole(RoleBean roleBean);

    int updateRole(RoleBean roleBean);

    int deleteRoleById(@Param("id") String id);

    int deleteRoleList(@Param("ids") List<String> ids);

    RoleBean querySingleRole(RoleBean roleBean);

    List<RoleBean> queryRoleList(@Param("roleBean") RoleBean roleBean, @Param("queryBean") BaseQueryBean queryBean);

    Long queryRoleListCount(@Param("roleBean") RoleBean roleBean);

    int deleteRoleAppByRoleId(String roleId);

    int deleteRoleOrgByRoleId(String roleId);

    int deleteRoleMenuByRoleId(String roleId);

    int deleteRoleMenuFuncByRoleId(String roleId);

    int deleteRoleStaffOrgByRoleId(String roleId);

    int insertRoleAppList(@Param("list") List<AppSimpleBean> appList);

    int insertRoleOrgList(@Param("list") List<OrgJurisdictionBean> orgList);

    int insertRoleMenuList(@Param("list") List<MenuJurisdictionBean> menuList);

    int insertRoleMenuFuncList(@Param("list") List<MenuFuncBean> menuFuncList);

    int insertRoleStaffOrgList(@Param("list") List<RoleStaffBean> staffList);

    List<AppSimpleBean> queryAppJurisdiction(@Param("roleId") String roleId);

    List<OrgTypeTreeVo> queryOrgJurisdiction(@Param("roleId") String roleId, @Param("appId") String appId);

    List<MenuTreeVo> queryMenuJurisdiction(@Param("roleId") String roleId, @Param("appId") String appId);

    List<MenuJurisdictionBean> queryMenuJurisdictionSimple(@Param("roleId") String roleId, @Param("appId") String appId);

    List<RoleStaffBean> queryUserJurisdiction(@Param("roleId") String roleId);

    List<AppJurisdictionBean> queryAppAllInfoJurisdiction(@Param("roleId") String roleId, @Param("appId") String appId);

    /*查询用户角色*/
    List<RoleBean> queryUserRole(@Param("account") String account);

    /*查询用户角色去重*/
    List<RoleBean> queryUserRoleDistinct(@Param("account") String account, @Param("preRoleIds") List<String> preRoleIds);

    /*通过账号,角色id删除用户角色*/
    int deleteUserRole(@Param("account") String account, @Param("roleId") String roleId);

    /*通过角色id查询应用权限*/
    List<AppSimpleBean> queryAppJurisdictionByRoleIds(@Param("roleIds") List<String> roleIds);

    /*通过角色id查询组织权限*/
    List<OrgTypeTreeVo> queryOrgJurisdictionByRoleIds(@Param("roleIds") List<String> roleIds);

    /*通过角色id查询菜单权限*/
    List<AppMenuJurisdictionBean> queryMenuJurisdictionSimpleByRoleIds(@Param("roleIds") List<String> roleIds, @Param("mark") String mark);

    /*通过角色id查询应用组织权限*/
    List<AppOrgJurisdictionBean> queryAppOrgJurisdictionByRoleIds(@Param("roleIds") List<String> roleIds);

    /*通过用户id查询账号列表*/
    List<String> queryAccountListByUserIds(@Param("ids") List<String> ids);

    /*批量删除用户角色列表*/
    int deleteUserRoleByAccountList(@Param("accountList") List<String> accountList);
}
